/**
未遂事故的修改页面
*/
<template>
  <div class="app-container">
    <!-- Note that row-key is necessary to get a correct row order. -->
    未事故单编号：<input

      v-model="faultId"
      type="text"
    >
    未遂事故单题目<input

      v-model="faultTitle"
      type="text"
    >
    <div> <button
      id="btnModify"
      type="button"
      class="btn btn-default btn-clean"
      @click="handleEdit()"
    >提交</button></div>
  </div>
</template>

<script>

// arr to obj, such as { CN : "China", US : "USA" }

import { editFaultList, editFault } from '@/api/fault'

export default {
  name: 'FaultEdit',
  data() {
    return {
      faultId: null,
      obj: null,
      faultTitle: null
    }
  },
  created() {
    this.faultId = this.$route.query.faultId
    this.fechData()
  },
  methods: {
    fechData() {
      console.log(this.faultId)
      editFaultList(this.faultId).then(response => {
        this.editList = response
        this.obj = response
        this.faultId = response.faultId
        this.faultTitle = response.faultTitle
        console.log('wo' + response)
      })
    },
    handleEdit() {
      const query = { faultId: this.faultId, faultTitle: this.faultTitle }
      editFault(query).then(response => {
        this.obj = response
        this.faultId = response.faultId
        this.faultTitle = response.faultTitle
        console.log('修改后' + response)
        alert('修改成功')
      })
      // 刷新页面
      location.reload()
    }
  }
}

</script>

<style>
.sortable-ghost{
  opacity: .8;
  color: #fff!important;
  background: #42b983!important;
}
</style>

<style scoped>
.icon-star{
  margin-right:2px;
}
.drag-handler{
  width: 20px;
  height: 20px;
  cursor: pointer;
}
.show-d{
  margin-top: 15px;
}
</style>
